Skip to content

8370493: [ubsan] aotMapLogger.cpp:864:44: runtime error: applying non-zero offset NNNNN to null pointer - #32057

Open
matias9927 wants to merge 1 commit into
openjdk:masterfrom
matias9927:aotMapLogger_8370493
Open

8370493: [ubsan] aotMapLogger.cpp:864:44: runtime error: applying non-zero offset NNNNN to null pointer#32057
matias9927 wants to merge 1 commit into
openjdk:masterfrom
matias9927:aotMapLogger_8370493

Conversation

@matias9927

@matias9927 matias9927 commented Jul 27, 2026

Copy link
Copy Markdown
Contributor

The UBSAN tool found undefined behavior in the aotMapLogger which relates to JDK-8366062. This patch applies an updated fix for both issues that places address + offset calculations in archiveUtils with proper casting to avoid the UBSAN error. Verified with tier 1-5 tests.



Progress

  • Change must not contain extraneous whitespace
  • Commit message must refer to an issue
  • Change must be properly reviewed (2 reviews required, with at least 1 Reviewer, 1 Author)

Issue

  • JDK-8370493: [ubsan] aotMapLogger.cpp:864:44: runtime error: applying non-zero offset NNNNN to null pointer (Enhancement - P4)

Reviewers

Reviewing

Using git

Checkout this PR locally:
$ git fetch https://git.openjdk.org/jdk.git pull/32057/head:pull/32057
$ git checkout pull/32057

Update a local copy of the PR:
$ git checkout pull/32057
$ git pull https://git.openjdk.org/jdk.git pull/32057/head

Using Skara CLI tools

Checkout this PR locally:
$ git pr checkout 32057

View PR using the GUI difftool:
$ git pr show -t 32057

Using diff file

Download this PR as a diff file:
https://git.openjdk.org/jdk/pull/32057.diff

Using Webrev

Link to Webrev Comment

@bridgekeeper

bridgekeeper Bot commented Jul 27, 2026

Copy link
Copy Markdown

👋 Welcome back matsaave! A progress list of the required criteria for merging this PR into master will be added to the body of your pull request. There are additional pull request commands available for use with this pull request.

@openjdk

openjdk Bot commented Jul 27, 2026

Copy link
Copy Markdown

@matias9927 This change now passes all automated pre-integration checks.

ℹ️ This project also has non-automated pre-integration requirements. Please see the file CONTRIBUTING.md for details.

After integration, the commit message for the final commit will be:

8370493: [ubsan] aotMapLogger.cpp:864:44: runtime error: applying non-zero offset NNNNN to null pointer

Reviewed-by: dholmes, amitkumar

You can use pull request commands such as /summary, /contributor and /issue to adjust it as needed.

At the time when this comment was updated there had been 89 new commits pushed to the master branch:

As there are no conflicts, your changes will automatically be rebased on top of these commits when integrating. If you prefer to avoid this automatic rebasing, please check the documentation for the /integrate command for further details.

➡️ To integrate this PR with the above commit message to the master branch, type /integrate in a new comment.

@openjdk openjdk Bot added the hotspot-runtime hotspot-runtime-dev@openjdk.org label Jul 27, 2026
@openjdk

openjdk Bot commented Jul 27, 2026

Copy link
Copy Markdown

@matias9927 The following label will be automatically applied to this pull request:

  • hotspot-runtime

When this pull request is ready to be reviewed, an "RFR" email will be sent to the corresponding mailing list. If you would like to change these labels, use the /label pull request command.

@openjdk

openjdk Bot commented Jul 27, 2026

Copy link
Copy Markdown

The total number of required reviews for this PR has been set to 2 based on the presence of this label: hotspot-runtime. This can be overridden with the /reviewers command.

@openjdk openjdk Bot added the rfr Pull request is ready for review label Jul 27, 2026
@mlbridge

mlbridge Bot commented Jul 27, 2026

Copy link
Copy Markdown

Webrevs

@dholmes-ora dholmes-ora left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems a reasonable workaround. Thanks.

@offamitkumar offamitkumar left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would have updated two more location with address + offset, but current changes are also fine by me.

diff --git a/src/hotspot/share/cds/archiveBuilder.cpp b/src/hotspot/share/cds/archiveBuilder.cpp
index 0b046a527cd..17ab60b465d 100644
--- a/src/hotspot/share/cds/archiveBuilder.cpp
+++ b/src/hotspot/share/cds/archiveBuilder.cpp
@@ -1049,7 +1049,7 @@ class RelocateBufferToRequested : public BitMapClosure {
     address bottom = _builder->buffer_bottom();
     address top = _builder->buffer_top();
     address new_bottom = ArchiveUtils::offset_to_requested_addr(bottom, _buffer_to_requested_delta);
-    address new_top = top + _buffer_to_requested_delta;
+    address new_top = ArchiveUtils::offset_to_requested_addr(top, _buffer_to_requested_delta);
     aot_log_debug(aot)("Relocating archive from [" INTPTR_FORMAT " - " INTPTR_FORMAT "] to "
                    "[" INTPTR_FORMAT " - " INTPTR_FORMAT "]",
                    p2i(bottom), p2i(top),
@@ -1114,7 +1114,7 @@ void ArchiveBuilder::relocate_to_requested() {
     patcher.doit();
   } else {
     assert(CDSConfig::is_dumping_dynamic_archive(), "must be");
-    _requested_dynamic_archive_top = _requested_dynamic_archive_bottom + my_archive_size;
+    _requested_dynamic_archive_top = ArchiveUtils::offset_to_requested_addr(_requested_dynamic_archive_bottom, my_archive_size);
     RelocateBufferToRequested<false> patcher(this);
     patcher.doit();
   }

@openjdk openjdk Bot added the ready Pull request is ready to be integrated label Jul 28, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

hotspot-runtime hotspot-runtime-dev@openjdk.org ready Pull request is ready to be integrated rfr Pull request is ready for review

Development

Successfully merging this pull request may close these issues.

3 participants